package com.flex.view
{
	import General.FRateLimiter;
	import General.Input;
	
	import TestBed.Test;
	import TestBed.TestTheoJansen;
	
	import com.adobe.cairngorm.view.ViewHelper;
	
	import flash.display.Sprite;
	import flash.events.Event;
	
	import mx.core.UIComponent;
	
	public class GameWindowHelper extends ViewHelper
	{
		
		private var i:int = 0;
		public function GameWindowHelper()
		{
			super();
			m_sprite = new Sprite();
		//	m_input = new Input(m_sprite);
		}
		
		public function initView():void{	
			m_sprite = new Sprite();
			
			view.uiCom.graphics.beginFill(0x00FF00,0.3);
			view.uiCom.graphics.drawRect(0,-200,800,600);
			view.uiCom.graphics.endFill();
			
			m_input = new Input(m_sprite,view.uiCom);
			(view.uiCom as UIComponent).addChild(m_sprite); 
			(view as Sprite).addEventListener(Event.ENTER_FRAME, updateView, false, 0, true);
		}
		
		public function updateView(e:Event):void{
	
			
			m_sprite.graphics.clear();
			
			
			if (!m_currTest){			
				m_currTest = new TestTheoJansen();
			}
			m_currTest.Update();
			
			if (Input.isKeyPressed(39)){ // Right Arrow
						
				trace("右");
			}
			
			//Input.update();
			FRateLimiter.limitFrame(30);
		}
		
		static public var m_sprite:Sprite;
		static public var m_currTest:Test;
		
		public var m_input:Input;
	}
	
}